<template>
	<view class="container">
		<view class="content">
			<view class="List">
				<view class="item" v-for="(item,index) in search(searchValue)" :key="inedx" @click="lookclick" v-bind:id="item.id">
					<view class="userCompany">{{item.activateAddress}}</view>
					<view class="time">
						<view class="left">
							<!-- <text>{{index+1}}.</text> -->
							<text>{{item.activateTime}}</text>
						</view>
						<view class="right">
							{{item.driverName}}
						</view>
					</view>
					
				</view>
			</view>
		</view>
		<uni-fab ref="fab" :pattern="pattern" :horizontal="horizontal" :vertical="vertical" :direction="direction"
			@fabClick="fabClick" v-if="!activateState" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '登录适配',
				list: [],
				searchValue:'',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				horizontal: 'right',
				vertical: 'bottom',
				direction: 'horizontal',
				activateState:false,
			}
		},

		onLoad() {
			uni.$on("getlist", (data) => {
				this.getList()
			})
		},
		created() {
			this.getList()

		},
		methods: {
		async	getList() {
			await	this.request({
					'url': '/wx/product/info/'+this.$store.getters.productId,
					'method': 'get',
				}).then(res => {
					console.log(res)
					if (res && res.code == 200) {
						this.activateState = res.info.activateState
					}
				}).catch(err => {
					
				})
				console.log(this.$store.getters.productId)
				await	this.request({
					'url': '/wx/project/activate/list/' + this.$store.getters.productId,
					'method': 'get',
				}).then(res => {
					console.log(res)
					if (res && res.code == 200) {
						this.list = res.list
					}
				}).catch(err => {

				})
			},
			fabClick() {
				// uni.showToast({
				// 	title: '点击了悬浮按钮',
				// 	icon: 'none'
				// })
				wx.navigateTo({
					url: '/pages/activation/activation?activateState='+this.activateState
				})
			},
			lookclick(e) {
				console.log(e)
				let url = '/pages/activation/look?id=' + e.currentTarget.id+'&activateState='+this.activateState
				wx.navigateTo({
					url: url
				})
			},
			search(res) {
				console.log(res)
				return this.list.filter((item) => {
				        if (item.activateAddress.match(new RegExp(res, "i"))) {
				          return item;
				        }
				      });
				
			},
			isAuth (key) {
			  return JSON.parse(uni.getStorageSync('permissions') || '[]').indexOf(key) !== -1 || false
			}
		}
	}
</script>

<style>
	.container {
		padding: 10px;
		background-color: #fff;
		height: 100%;
		box-sizing: border-box;
	}

	.item {
		
		background-color: #fff;
		box-shadow: 0px 0px 10px #e2e2e2;
		border-radius: 10px;
		/* height: 50px; */
		padding: 10px 10px;
		font-size: 14px;
		margin-bottom: 10px;
	}
	.time{
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 30px;
		color: #999;
	}
	.left {
		width: 60%;
		padding-right: 10px;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
	}

	.right {
		text-align: right;
		width: 40%;
	}
	.userCompany{
		font-weight: 600;
		line-height: 30px;
	}
</style>